package com.bw.controller;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.bw.bean.TmsA;
import com.bw.service.TmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class TmsController {
    @Autowired
    TmsService service;

    @RequestMapping("listA")
    public JSONObject listA(){
        List<TmsA> tmsAS = service.listA();
        JSONObject jsonObject = new JSONObject();

        jsonObject.put("status",0);
        jsonObject.put("msg","");

        JSONArray objects = new JSONArray();

        for (TmsA tmsA : tmsAS) {
            JSONObject jsonObject1 = new JSONObject();
            jsonObject1.put("name",tmsA.getName());
            jsonObject1.put("value",tmsA.getZb());
            objects.add(jsonObject1);
        }

        jsonObject.put("data",objects);

        return jsonObject;
    }
}
